/*
 * Copyright (c) 2006, 2023, webrx.cn All rights reserved.
 *
 */

package cn.webrx;

import java.io.FileInputStream;
import java.io.FileOutputStream;

/**
 * <p>Project: jse2303 - Stream1
 * <p>Powered by webrx On 2023-07-21 10:45:57
 * <p>描述：<p>
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Stream1 {
    public static void main(String[] args) {
        //写入文件 输入流OutputStream FileOutputStream()
        try (FileOutputStream fos = new FileOutputStream("m.txt", true)) {
            //fos.write(97);
            //fos.write("97".getBytes());
            //fos.write("\r\n".getBytes());
            //fos.write("汉字\r\n".getBytes());
        } catch (Exception e) {

        }

        //读取文件 InputStream FileInputStream()
        try (var is = new FileInputStream("m.txt")) {
            int len = is.available();
            //System.out.println(len);
            byte[] bytes = is.readAllBytes();
            //System.out.println(bytes.length);

            //将字节数组转换为String
            String str = new String(bytes);
            System.out.println(str);
        } catch (Exception e) {

        }
    }
}
